#include "Vertex.h"

int Vertex::VertexCount=0;

Vertex::Vertex(QPointF point,int r,QGraphicsEllipseItem* parent):
    QGraphicsEllipseItem(point.x()-2*r,point.y()-2*r,5*r,3*r,parent),
    point(point),
    r(r)
{
    id=VertexCount++;
    //text=QString::number(VertexCount++);
    selected=0;
}

void Vertex::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    painter->setPen(Qt::NoPen);
    painter->setBrush(RegBrush);
    if(selected==1)
        painter->setBrush(SelBrush);
    painter->setRenderHint(QPainter::Antialiasing,true);
    painter->drawEllipse(QRectF(point.x()-r,point.y()-r,2*r,2*r));
    painter->setFont(TagFont);
    painter->setPen(Qt::black);
    painter->drawText(QPointF(point.x(),point.y()),QString::number(id));
}
